package com.by.zhdoctor.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

/**
 * A ZhengXing.
 */
@Entity
@Table(name = "zheng_xing")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class ZhengXing implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(name = "zx_name")
    private String zxName;

    @ManyToOne
    private BingMing bingming;

    @OneToOne(mappedBy = "zhengxing")
    @JsonIgnore
    private ChuFang chufang;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getZxName() {
        return zxName;
    }

    public ZhengXing zxName(String zxName) {
        this.zxName = zxName;
        return this;
    }

    public void setZxName(String zxName) {
        this.zxName = zxName;
    }

    public BingMing getBingming() {
        return bingming;
    }

    public ZhengXing bingming(BingMing bingMing) {
        this.bingming = bingMing;
        return this;
    }

    public void setBingming(BingMing bingMing) {
        this.bingming = bingMing;
    }

    public ChuFang getChufang() {
        return chufang;
    }

    public ZhengXing chufang(ChuFang chuFang) {
        this.chufang = chuFang;
        return this;
    }

    public void setChufang(ChuFang chuFang) {
        this.chufang = chuFang;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ZhengXing zhengXing = (ZhengXing) o;
        if (zhengXing.id == null || id == null) {
            return false;
        }
        return Objects.equals(id, zhengXing.id);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(id);
    }

    @Override
    public String toString() {
        return "ZhengXing{" +
            "id=" + id +
            ", zxName='" + zxName + "'" +
            '}';
    }
}
